package com.nvwa.mvp.webstater.controller;

import com.nvwa.boot.stater.web.environment.EnvironmentChecker;
import com.nvwa.dto.err.DefErrorCodeEnum;
import com.nvwa.dto.resp.Response;
import com.nvwa.mvp.webstater.err.MyException;
import com.nvwa.mvp.webstater.form.UserForm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private EnvironmentChecker environmentChecker;

    @GetMapping("/get")
    public Response getUser() {
        String environmentActiveCode = environmentChecker.getEnvironmentActiveCode();
        log.info("---environmentActiveCode: {}", environmentActiveCode);

        boolean production = environmentChecker.isProduction();
        System.out.println("---production:" + production);
        return Response.success();
    }

    @PostMapping("/saveUser")
    public Response saveUser(@RequestBody UserForm userForm) {
//        throw new RuntimeException("hello");
        throw new MyException(DefErrorCodeEnum.PARAM_ERROR);
//        return Response.success();
    }


}